<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    .arrow_box {
        animation: glow 800ms ease-out infinite alternate;
    }

    @keyframes glow {
        0% {
            border-color: #831F20;
            box-shadow: 0 0 5px rgba(255, 0, 0, .2), inset 0 0 5px rgba(255, 0, 0, .1), 0 1px 0 #831F20;
        }
        100% {
            border-color: #AD1415;
            box-shadow: 0 0 20px rgba(255, 0, 0, .6), inset 0 0 10px rgba(255, 0, 0, .4), 0 1px 0 #AD1415;
        }
    }

    /*重新设置样式*/
    .form-control {
        width: 196px !important;
        height: 34px !important;
        padding: 10px !important;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini" onload="checkBrowser()">
<div class="modal fade" id="modal-viewAdj">
    <div class="modal-dialog" style="width:80%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="viewAdjTitle">查看库存调整</h4>
            </div>
            <div class="modal-body">
                <form id="viewForm" class="form-horizontal">

                    <div class="row">
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">物料描述</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjMatDesc" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库数量</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="adjNum" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单价（元）</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="adjPrice" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjUnit" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">SAP物料编码</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjMatCode" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目编号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjProCode"
                                               placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjProName"
                                               placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">跟踪号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjTrackCode" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">区位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjPosition" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">仓库</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="whiName" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库类型</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjStockTypeText"
                                               placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">备注</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjSpec" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">调整原因</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="adjReason"
                                               placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

                <div class="row">
                    <div class="col-md-10 col-md-offset-1">
                        <form id="viewFormCompareBefore" class="form-horizontal">
                            <div class="col-md-6">
                                <div class="col-md-12">
                                    <div class="form-group" style="text-align:center">
                                        <h4>调整前</h4>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">物料描述</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjMatDesc" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">在库数量</label>
                                        <div class="col-sm-8">
                                            <input type="value" class="form-control" name="adjNum" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">单价（元）</label>
                                        <div class="col-sm-8">
                                            <input type="value" class="form-control" name="adjPrice" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">单位</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjUnit" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">SAP物料编码</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjMatCode" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">项目编号</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjProCode"
                                                   placeholder="" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">项目名称</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjProName"
                                                   placeholder="" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">跟踪号</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjTrackCode" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">区位</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjPosition" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">仓库</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="whiName" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">在库类型</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjStockTypeText"
                                                   placeholder="" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">备注</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjSpec" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">机械备件库备注类型</label>
                                        <div class="col-sm-8">
                                            <input type="text" readonly="readonly" class="form-control" name="adjRemarkType" placeholder="">
                                        </div>
                                    </div>
                                </div>
                                <!--<div class="col-md-12">-->
                                <!--<div class="form-group">-->
                                <!--<label class="col-sm-4 control-label">调整原因</label>-->
                                <!--<div class="col-sm-8">-->
                                <!--<input type="text" class="form-control" name="adjReason"-->
                                <!--placeholder="" readonly="readonly">-->
                                <!--</div>-->
                                <!--</div>-->
                                <!--</div>-->
                            </div>
                        </form>
                        <form id="viewFormCompareAfter" class="form-horizontal">
                            <div class="col-md-6">
                                <div class="col-md-12">
                                    <div class="form-group" style="text-align:center">
                                        <h4>调整后</h4>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">物料描述</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjMatDesc" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">在库数量</label>
                                        <div class="col-sm-8">
                                            <input type="value" class="form-control" name="adjNum" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">单价（元）</label>
                                        <div class="col-sm-8">
                                            <input type="value" class="form-control" name="adjPrice" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">单位</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjUnit" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">SAP物料编码</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjMatCode" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">项目编号</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjProCode"
                                                   placeholder="" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">项目名称</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjProName"
                                                   placeholder="" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">跟踪号</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjTrackCode" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">区位</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjPosition" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">仓库</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="whiName" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">在库类型</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjStockTypeText"
                                                   placeholder="" readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">备注</label>
                                        <div class="col-sm-8">
                                            <input type="text" class="form-control" name="adjSpec" placeholder=""
                                                   readonly="readonly">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label">机械备件库备注类型</label>
                                        <div class="col-sm-8">
                                            <input type="text" readonly="readonly" class="form-control" name="adjRemarkType" placeholder="">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                        <div class="col-md-12" id="adjReasonDiv">
                            <form class="form-horizontal">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="text-align: right">调整原因</label>
                                    <div class="col-sm-10" style="padding-left: 20px;padding-right: 29px">
                                        <input type="text" class="form-control" id="adjReason" name="adjReason"
                                               placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="modal-edit">
    <div class="modal-dialog" style="width:80%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" id="btn_modal_edit_close_x" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">修改库存调整</h4>
            </div>
            <div class="modal-body">
                <form id="editForm" class="form-horizontal">
                    <input type="hidden" id="adjId" name="adjId">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">物料描述</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjMatDesc" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库数量</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="adjNum" placeholder="">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单价（元）</label>
                                    <div class="col-sm-8">
                                        <input type="value" class="form-control" name="adjPrice" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">单位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjUnit" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">SAP物料编码</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjMatCode" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目编号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjProCode"
                                               placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">项目名称</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjProName"
                                               placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">跟踪号</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjTrackCode" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">区位</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjPosition" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">仓库</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="whiName" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">在库类型</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjStockTypeText"
                                               placeholder="" readonly="readonly">
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">备注</label>
                                    <div class="col-sm-8">
                                        <input type="text" class="form-control" name="adjSpec" placeholder=""
                                               readonly="readonly">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">调整原因</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="adjReason"
                                               placeholder="">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="btn-adj-save"
                        shiro:hasPermission="halinv:haladjapp:edit">保存
                </button>
                <button type="button" class="btn btn-default" id="btn_modal_edit_close" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<section class="content-header">
    <h1>库存调整审批列表</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header" style="padding-bottom: 0px">
                    <form id="queryForm">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label>项目编号</label>
                                    <input type="text" name="adjProCode" class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label>项目名称</label>
                                    <input type="text" name="adjProName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label>物料描述</label>
                                    <input type="text" name="adjMatDesc" class="form-control"
                                           placeholder="请输入物料描述"
                                    />
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label>仓库</label>
                                    <select name="adjWhiId" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 100px!important;">

                                        <option value="" selected="selected">全部</option>
                                        <option th:each="whiIds:${whiIds}" th:value="${whiIds.whiId}"
                                                th:text="${whiIds.whiName}"></option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label>调整状态</label>
                                    <select name="adjStatus" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 100px!important;">
                                        <option value="2" selected="selected">未审核</option>
                                        <option value="3">审核通过</option>
                                        <option value="4">审核未通过</option>
                                        <option value="">全部</option>
                                    </select>
                                </div>
                                <div class="form-group" style="margin-right: 10px;margin-bottom: 5px">
                                    <label>调整类型</label>

                                    <select name="adjTypes" class="form-control"
                                            style="padding: 0px!important;text-align: center!important;text-align-last: center!important;width: 120px!important;">
                                        <option value="1" selected="selected">全部</option>
                                        <option value="2">申请调整</option>
                                        <option value="3">盘点调整</option>
                                        <option value="4">新增调整</option>
                                        <option value="5">盘点新增调整</option>
                                    </select>

                                </div>
                                <div class="form-group" style="margin: 0px;padding: 0px">
                                    <label>申请日期</label>
                                    <input name="startDate" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly"> -
                                    <input name="endDate" type="text"
                                           class="form-control datepicker" style="width: 100px!important;"
                                           readonly="readonly">
                                </div>

                                <div class="form-group" style="margin: 0px;padding: 0px">

                                    <button type="button" class="btn btn-success pull-right" id="btn-search">
                                        <span class="Bold">&emsp;搜索&emsp;</span>
                                    </button>


                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="row" id="toolbar">
                    <button shiro:hasPermission="purinv:puradjapp:edit"
                            type="button" class="btn btn-success"
                            id="btn-review-adopt">
                        <span class="Bold">批量通过</span>
                    </button>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>

<div th:include="include :: footer"></div>
<script th:inline="javascript">

    var applyStatusText = ["", "未提交", "未审核", "审核通过", "审核不通过"];
    var applyStatusColor = ["", " bg-gray", " bg-gray", " bg-green", " bg-red"];
    var table;

    function checkBrowserFun() {
        let is360 = false;
        let isIE = false;
        let isFirefox = false;
        let isChrome = false;
        let isEdge = false;
        let broName = 'Runing';
        let str = '';
        let strStart = 0;
        let strStop = 0;
        let arr = new Array();
        let temp = '';
        let userAgent = window.navigator.userAgent; //包含以下属性中所有或一部分的字符串：appCodeName,appName,appVersion,language,platform
        /*alert(userAgent);*/
        //FireFox
        if (userAgent.indexOf('Firefox') != -1) {
            isFireFox = true;
            /*broName = 'FireFox浏览器';*/
            strStart = userAgent.indexOf('Firefox');
            temp = userAgent.substring(strStart);
            broName = temp.replace('/', '版本号')

        }
        //Edge
        if (userAgent.indexOf('Edge') != -1) {
            isEdge = true;
            /*broName = 'Edge浏览器';*/
            strStart = userAgent.indexOf('Edge');
            temp = userAgent.substring(strStart);
            broName = temp.replace('/', '版本号');
        }
        //IE浏览器
        if (userAgent.indexOf('NET') != -1 && userAgent.indexOf("rv") != -1) {
            isIE = true;
            /*broName = 'IE浏览器'; */
            strStart = userAgent.indexOf('rv');
            strStop = userAgent.indexOf(')');
            temp = userAgent.substring(strStart, strStop);
            broName = temp.replace('rv', 'IE').replace(':', '版本号');
        }
        //360极速模式可以区分360安全浏览器和360极速浏览器
        if (userAgent.indexOf('WOW') != -1 && userAgent.indexOf("NET") < 0 && userAgent.indexOf("Firefox") < 0) {
            if (navigator.javaEnabled()) {
                is360 = true;
                broName = '360安全浏览器-极速模式';
            } else {
                is360 = true;
                broName = '360极速浏览器-极速模式';
            }
        }
        //360兼容
        if (userAgent.indexOf('WOW') != -1 && userAgent.indexOf("NET") != -1 && userAgent.indexOf("MSIE") != -1 && userAgent.indexOf("rv") < 0) {
            is360 = true;
            broName = '360兼容模式';
        }
        //Chrome浏览器
        if (userAgent.indexOf('WOW') < 0 && userAgent.indexOf('Chrome') > 0 && userAgent.indexOf("Edg") < 0) {
            isChrome = true;
            /*broName = 'Chrome浏览器';*/
            strStart = userAgent.indexOf('Chrome');
            strStop = userAgent.indexOf(' Safari');
            temp = userAgent.substring(strStart, strStop);
            broName = temp.replace('/', '版本号');
        }
        return isChrome;
    }

    /**
     * 检测浏览器
     * */
    function checkBrowser() {
        if (!checkBrowserFun()) {
            alert("尊敬的客户，您使用浏览器不是谷歌浏览器，请使用谷歌浏览器访问本系统！");
            location.href = ctx + "overview/index";
        }
    }

    $(function () {
        $("title").html($("title").html() + " —— 外购件库存调整审批");
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "purchase/adjust/review/list",
            showColumns: true,
            showExport: false,
            pageSize: 300,
            rowStyle: function (row, index) {
                if (row.adjPid == null) {
                    return {css: {"border-top-color": "#333"}}
                } else {
                    return {css: {"border-bottom-color": "#333"}}
                }
            },
            onLoadSuccess: function (data) {
                mergeCells(data, "adjCode", "adjStatus", 1, $('#bootstrap-table')); //合并单元格
                mergeCells(data, "adjCode", "adjOdaId", 1, $('#bootstrap-table')); //合并单元格
                // //合并操作单元格
                // var pre = false;
                // var htmlArray = new Array();
                // var rowspanArray = new Array();
                // $("#bootstrap-table tbody tr").each(function (i) {
                //     $(this).children("td").eq(14).each(function (j) {
                //         if ($(this).html() == '') {
                //             $(this).remove();
                //             pre = true
                //         } else if (pre) {
                //             $(this).attr("rowspan", "2");
                //             htmlArray.push($(this).prop("outerHTML"));
                //             rowspanArray.push(2);
                //             pre = false;
                //             $(this).remove();
                //         } else {
                //             htmlArray.push($(this).prop("outerHTML"));
                //             $(this).remove();
                //             rowspanArray.push(1);
                //         }
                //     });
                //
                // })
                // var trIndex = 0;
                // var arrayIndex = -1;
                // $("#bootstrap-table tbody tr").each(function (i) {
                //     $(this).append(htmlArray[trIndex])
                //     trIndex++;
                //     if (rowspanArray[arrayIndex] == 2) {
                //         return true
                //     }
                //     arrayIndex++;
                //
                // })


            },
            columns: [
                {
                    title: '<input class="checkboxAll"  type="checkbox" onclick="selectedAll()" >',
                    field: 'adjOdaId',
                    // title: '<checkbox:true>',
                    formatter: function (value, row, index) {
                        if (row.adjStatus == 2 || row.adjStatus == 4) {
                            if (row.adjNewFlag == 1) {
                                return '<input class="checkbox_select"  type="checkbox" name= "checkbox_select" value="' + row.adjId + '">';
                            } else if (row.adjNewFlag != 1) {
                                return checkIsParents(row.adjId);
                            } else {
                                return "";
                            }
                        } else {
                            return "";
                        }
                    }
                },
                {title: '物料描述', field: 'adjMatDesc', width: '150'},
                {
                    title: '调整量', field: 'adjDValue', formatter: function (value, row, index) {
                        var styleText = "";
                        if (Number(value) > 0) {
                            styleText = "style='color:green'";
                        } else if (Number(value) < 0) {
                            styleText = "style='color:red;font-weight:900'";
                        } else {
                            styleText = "style='color:#333333'";
                        }
                        return '<span ' + styleText + '>' + value + '</span>';
                    }
                },
                {title: '单位', field: 'adjUnit', width: '50'},
                {
                    title: '调整单价</br>（元）', field: 'adjPrice', formatter: function (value, row, index) {
                        if (hasP('purinv:amount:view')) {
                            if (value == undefined || value == null) {
                                return "--";
                            }
                            if (row.adjIdentity == 1) {
                                return value;
                            }
                            return value;
                        }
                        return "***";
                    }
                },
                {
                    title: '调整金额</br>（元）', field: 'adjAmount', formatter: function (value, row, index) {
                        if (hasP('purinv:amount:view')) {
                            if (value == undefined || value == null) {
                                return "--";
                            }

                            if (row.adjIdentity == 1) {
                                return Math.round(eval(row.adjPrice * row.adjDValue) * 1000) / 1000;
                            }
                            return Math.round(eval(row.adjPrice * row.adjDValue) * 1000) / 1000;
                        }
                        return "***";
                    }
                },
                {
                    title: '项目名称', field: 'adjProName', width: '150', formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },
                {
                    title: '项目编号', field: 'adjProCode', width: '150', formatter: function (value, row, index) {
                        if (value == undefined || value == null) {
                            value = "--";
                        }
                        return value;
                    }
                },
                {
                    title: '仓库', field: 'adjWhiIdName', width: '110',
                    formatter: function (value, row, index) {
                        return value;
                    }
                },
                {title: '调整原因', field: 'adjReason'},
                {
                    title: '调整类型', width: '110', formatter: function (value, row, index) {
                        if (row.adjNewFlag == 1 && row.adjType == 1) {
                            return '<span class="badge label-success">' + '新增调整' + '</span> ';
                        } else if (row.adjNewFlag == 0 && row.adjType == 1) {
                            return '<span class="badge label-warning">' + '申请调整' + '</span> ';
                        } else if (row.adjNewFlag == 0 && row.adjType == 2) {
                            return '<span class="badge label-info">' + '盘点调整' + '</span> ';
                        } else if (row.adjNewFlag == 1 && row.adjType == 2) {
                            return '<span class="badge label-info">' + '新增盘点调整' + '</span> ';
                        }
                    }
                }, {
                    title: '调整状态', field: 'adjStatus', width: '90',
                    formatter: function (value, row, index) {
                        if (value == undefined) {
                            return '';
                        }
                        var html = '<label class="badge ' + applyStatusColor[value] + '">' + applyStatusText[value] + '</label>';
                        return html;
                    }
                },
                {title: '申请人', field: 'adjApplicant', width: '70'},
                {title: '申请时间', field: 'adjAppDatetime', width: '100'},
                {
                    title: '操作', width: '200', field: 'adjCode"',
                    formatter: function (value, row, index) {

                        var actions = [];
                        if (hasP('purinv:puradjapp:view')) {
                            if (row.adjIdentity == 2)//调整单为后单
                            {
                                actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="openViewAdj(' + row.adjId + ',' + row.adjPid + ')"> 查看</a> ');
                            }
                        }
                        if (hasP('purinv:puradjapp:edit')) {
                            if (row.adjIdentity == 2)//调整单为后单
                            {
                                if (row.adjStatus == 2) {

                                    actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="reviewAdopt(' + row.adjId + ')"> 通  过</a> ');
                                    actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="reviewFail(' + row.adjId + ')"> 不通过</a> ');

                                }
                                if (row.adjStatus == 4) {
                                    actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="reviewAdopt(' + row.adjId + ')"> 通  过</a> ');
                                }
                            }
                        }

                        return actions.join('');
                    }
                }
            ]
        });

        $("#btn_modal_edit_close_x").on('click', function () {
            js.modal.hide("modal_edit");
            js.validate.reset("editForm");
            js.reset("editForm");
        });
        $("#btn_modal_edit_close").on('click', function () {
            js.modal.hide("modal_edit");
            js.validate.reset("editForm");
            js.reset("editForm");
        });

        /** 验证 */
        js.validate.init("editForm", {
            fields: {
                adjNum: {
                    validators:
                        {
                            notEmpty: {message: '请输入在库数量'},
                            digits: {message: '请输入数值'}
                        }
                },
                adjPrice: {validators: {digits: {message: '请输入数值'}}},
                adjUnit: {validators: {notEmpty: {message: '未输入单位'}}},
                adjMatDesc: {validators: {notEmpty: {message: '未输入物料描述'}}}
            }
        });

        /**
         * 保存修改库存调整
         */
        $("#btn-adj-save").click(function (aadId) {
            js.validSubmit({
                formId: "editForm",
                url: ctx + "purchase/adjust/apply/saveAdjust",
                data: new FormData($("#editForm")[0]),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.modal.hide("modal-edit");
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            });
        });

        // 批量提交
        $("#btn-review-adopt").click(function () {
            //获取checkbox[name='check']的值
            var arr = new Array();
            $('input[name="checkbox_select"]:checkbox:checked').each(function (i, value) {
                arr += $(this).attr("value") + ",";
            });
            if (arr.length <= 0) {
                js.modal.warning("请至少选择一个调整申请信息！");
                return false;
            }
            arr = arr.substring(0, arr.length - 1);
            js.modal.confirm("确定要批量提交库存调整申请吗?", function () {
                js.post({
                    url: ctx + "purchase/adjust/review/adopts",
                    data: {adjIds: arr},
                    success: function (result) {
                        if (result.type === web_status.SUCCESS) {
                            js.modal.success(result.msg);
                            js.table.refresh(table);
                            js.modal.closeLoading();
                            location.reload();
                        } else {
                            js.modal.warning(result.msg);
                        }
                    }
                })
            });
        });

        /**
         * 合并单元格
         * @param data 原始数据（在服务端完成排序）
         * @param fieldName 合并依据属性名称
         * @param spanFieldName 合并属性名称
         * @param colspan 合并列
         * @param target 目标表格对象
         */
        function mergeCells(data, fieldName, spanFieldName, colspan, target) {
            //声明一个map计算相同属性值在data对象出现的次数和
            var sortMap = {};
            for (var i = 0; i < data.rows.length; i++) {
                for (var prop in data.rows[i]) {
                    if (prop == fieldName) {
                        var key = data.rows[i][prop]
                        if (sortMap.hasOwnProperty(key)) {
                            sortMap[key] = sortMap[key] * 1 + 1;
                        } else {
                            sortMap[key] = 1;
                        }
                        break;
                    }
                }
            }
            var index = 0;
            for (var prop in sortMap) {
                var count = sortMap[prop] * 1;
                $(target).bootstrapTable('mergeCells', {
                    index: index,
                    field: spanFieldName,
                    colspan: colspan,
                    rowspan: count
                });
                index += count;
            }
        }

        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });

        // /**
        //  * 模态框隐藏事件， 重置表单，重置验证
        //  */
        // js.modal.hideEvent("modal-edit", function () {
        //     js.validate.reset("editForm");
        //     js.reset("editForm");
        // });
    });

    /**
     *@FunctionName: reviewAdopt
     *@Description: 审核通过
     *@Author: 徐一贺
     *@CreateDate: 2020/5/6 10:31
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function reviewAdopt(adjId) {
        js.modal.confirm("尊敬的用户，您确认要审核通过这条调整申请吗?", function () {
            $.post(ctx + 'purchase/adjust/review/adopt', {
                adjId: adjId
            }, function (result) {
                if (result.type = web_status.SUCCESS) {
                    js.table.refresh(table);
                    js.modal.msg(result.msg, alertStatus.SUCCESS)
                }
                if (result.type = web_status.error) {
                    js.modal.msg(result.msg, alertStatus.FAIL)
                }
            }, 'json')
        });
    }

    /**
     *@FunctionName: checkIsParents
     *@Description: 检测是否身份为父级
     *@Author: 徐一贺
     *@CreateDate: 2020/5/6 15:47
     *@Phone: 18241927380
     *@Param: [adjId] 被检测对象
     *@Return: [boolean] 如果身份为父级返回 true，否则返回flase
     *@Version: 1.0.0
     */
    function checkIsParents(adjId) {
        var data = $('#bootstrap-table').bootstrapTable('getData');
        for (var i = 0; i < data.length; i++) {
            if (data[i].adjPid == adjId) {
                return '<input class="checkbox_select"  type="checkbox" name= "checkbox_select" value="' + data[i].adjId + '">';
            }
        }
        return '<input class="checkbox_select"  type="checkbox" name= "checkbox_select" value="' + adjId + '">';
    }

    /**
     *@FunctionName: reviewAdopt
     *@Description: 审核不通过
     *@Author: 徐一贺
     *@CreateDate: 2020/5/6 10:31
     *@Phone: 18241927380
     *@Version: 1.0.0
     */
    function reviewFail(adjId) {
        js.modal.confirm("尊敬的用户，您确认要不通过这条调整申请吗?", function () {
            $.post(ctx + 'purchase/adjust/review/fail', {
                adjId: adjId
            }, function (result) {
                if (result.type = web_status.SUCCESS) {
                    js.table.refresh(table);
                    js.modal.msg(result.msg, alertStatus.SUCCESS)
                }
                if (result.type = web_status.error) {
                    js.modal.msg(result.msg, alertStatus.FAIL)
                }
            }, 'json')
        });
    }


    /**
     * 打开修改库存模态框
     */
    function openEditAdj(adjId) {
        js.post({
            url: ctx + "purchase/adjust/apply/getAdjust",
            data: {
                adjId: adjId
            },
            success: function (result) {
                $("#editForm").fillData(result.data);
                js.modal.open("modal-edit");
                js.modal.closeLoading();
            }
        })

    }

    /**
     * 批量删除
     */
    $("#btn-remove").on('click', function () {
        //获取checkbox[name='check']的值
        var arr = new Array();
        $('input[name="checkbox_select"]:checkbox:checked').each(function (i, value) {
            arr += $(this).attr("value") + ",";
        });
        if (arr.length <= 0) {
            js.modal.warning("请至少选择一个库存调整信息");
            return false;
        }
        arr = arr.substring(0, arr.length - 1);
        delAdj(arr);
    });

    /**
     *删除库存变更
     */
    function delAdj(adjIds) {
        js.modal.confirm("确认删除此变更吗？", function () {
            js.post({
                url: ctx + "purchase/adjust/apply/remove",
                data: {
                    adjIds: adjIds,
                    adjStatus: 0
                },
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            })
        })
    }


    /**
     * 查看库存调整申请
     */
    function openViewAdj(adjId, adjPid) {
        if (adjPid == null) {
            js.post({
                url: ctx + "purchase/adjust/apply/getAdjust",
                data: {
                    adjId: adjId
                },
                success: function (result) {
                    if (result.data.adjNewFlag == 1) {
                        $("#viewAdjTitle").html('查看新增库存调整');
                    } else {
                        $("#viewAdjTitle").html('查看库存调整');
                    }
                    $('#viewFormCompareBefore')[0].reset();
                    $('#viewFormCompareAfter')[0].reset();
                    $('#viewForm')[0].reset();
                    $("#viewFormCompareBefore").hide();
                    $("#viewFormCompareAfter").hide();
                    $("#adjReasonDiv").hide();
                    $("#viewForm").fillData(result.data);
                    $("#viewForm").show();
                    js.modal.open("modal-viewAdj");
                    js.modal.closeLoading();
                }
            });
        } else {
            js.post({
                url: ctx + "purchase/adjust/apply/getCompareAdjust",
                data: {
                    adjId: adjId,
                    adjPid: adjPid
                },
                success: function (result) {
                    if (result.data.adjNewFlag == 1) {
                        $("#viewAdjTitle").html('查看新增库存调整');
                    } else {
                        $("#viewAdjTitle").html('查看库存调整');
                    }
                    $('#viewFormCompareBefore')[0].reset();
                    $('#viewFormCompareAfter')[0].reset();
                    $('#viewForm')[0].reset();
                    $("#viewForm").hide();
                    $("#adjReasonDiv").show();
                    $("#adjReason").val("");
                    $("#viewFormCompareBefore").fillData(result.data.beforeAdjust);
                    $("#viewFormCompareAfter").fillData(result.data.afterAdjust);
                    $("#viewFormCompareBefore").show();
                    $("#viewFormCompareAfter").show();
                    //检测值如果修改后的值与之前的不同则用红框提示
                    if ($("#viewFormCompareBefore [name='adjMatDesc']").val() != $("#viewFormCompareAfter [name='adjMatDesc']").val()) {
                        $("#viewFormCompareAfter [name='adjMatDesc']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjMatDesc']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjNum']").val() != $("#viewFormCompareAfter [name='adjNum']").val()) {
                        $("#viewFormCompareAfter [name='adjNum']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjNum']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjPrice']").val() != $("#viewFormCompareAfter [name='adjPrice']").val()) {
                        $("#viewFormCompareAfter [name='adjPrice']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjPrice']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjUnit']").val() != $("#viewFormCompareAfter [name='adjUnit']").val()) {
                        $("#viewFormCompareAfter [name='adjUnit']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjUnit']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjMatCode']").val() != $("#viewFormCompareAfter [name='adjMatCode']").val()) {
                        $("#viewFormCompareAfter [name='adjMatCode']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjMatCode']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjProCode']").val() != $("#viewFormCompareAfter [name='adjProCode']").val()) {
                        $("#viewFormCompareAfter [name='adjProCode']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjProCode']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjProName']").val() != $("#viewFormCompareAfter [name='adjProName']").val()) {
                        $("#viewFormCompareAfter [name='adjProName']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjProName']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjTrackCode']").val() != $("#viewFormCompareAfter [name='adjTrackCode']").val()) {
                        $("#viewFormCompareAfter [name='adjTrackCode']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjTrackCode']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjPosition']").val() != $("#viewFormCompareAfter [name='adjPosition']").val()) {
                        $("#viewFormCompareAfter [name='adjPosition']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjPosition']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='whiName']").val() != $("#viewFormCompareAfter [name='whiName']").val()) {
                        $("#viewFormCompareAfter [name='whiName']").attr("class", "form-control arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='whiName']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjStockTypeText']").val() != $("#viewFormCompareAfter [name='adjStockTypeText']").val()) {
                        $("#viewFormCompareAfter [name='adjStockTypeText']").attr("form-control class", "arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjStockTypeText']").attr("class", "form-control");
                    }
                    if ($("#viewFormCompareBefore [name='adjSpec']").val() != $("#viewFormCompareAfter [name='adjSpec']").val()) {
                        $("#viewFormCompareAfter [name='adjSpec']").attr("form-control class", "arrow_box");
                    } else {
                        $("#viewFormCompareAfter [name='adjSpec']").attr("class", "form-control");
                    }
                    js.modal.open("modal-viewAdj");
                    js.modal.closeLoading();
                }
            });
        }

    }

    /**
     *全选
     */
    function selectedAll() {
        if ($('.checkboxAll').is(":checked")) {
            $('.checkbox_select').each(function () {
                this.checked = true;
            });
        } else {
            $('.checkbox_select').each(function () {
                this.checked = false;
            });
        }
    }


</script>
</body>
</html>